-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Vectorize pvlib.bifacial.utils._vf_ground_sky_2d
across surface_tilt
#1682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vectorize pvlib.bifacial.utils._vf_ground_sky_2d
across surface_tilt
#1682
Conversation
also a few other micro-optimizations
It occurred to me that this PR might have objectionably large memory requirements (similar to #1402) so I did some memory profiling and found that a call to The memory load is still larger than I'd like, but with that reduction I'd say it's an acceptable price to pay for the runtime improvement. I'm curious what others think. |
1 year of 1 minute data is about half a million points. If memory usage scales linearly with that dimension, then I think some users will run into a problem. |
Good point. Well, taking full advantage of numpy's Updated plot: |
If we add a |
I'm not a numpy expert, especially in regards to performance, but this looks reasonable to me. Perhaps a numba element by element calculation would combine readability, performance, and reasonable memory usage. Perhaps. |
Ok, I added a new Here's an asv runtime comparison:
|
This PR is ready for another look if @cwhanse or @wholmgren (or anyone else, of course) is interested. The new vectorized calculation path is now gated behind an optional |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kanderso-nrel this PR changes the output (shape of vf
) of bifacial.utils._solar_projection_tangent
. That's a private function, so I suppose a deprecation is optional. I'm OK without deprecation, but raising the issue in case there are differing opinions.
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
[ ] Tests added[ ] Updates entries indocs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).[ ] New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.remote-data
) and Milestone are assigned to the Pull Request and linked Issue.I could not get satisfactory benchmarking results using asv (perhaps this computer is too noisy for asv's defaults?) so I wrote a one-off benchmarking script that yielded the following runtime comparison for
infinite_sheds.get_irradiance()
with inputs for a generic single-axis tracking simulation:I don't deal with multidimensional numpy arrays very often. I will happily make changes if what I've done here is unnecessarily clunky or inefficient and someone suggests improvements.